<%-- 
    Document   : orderDetail
    Created on : Apr 21, 2013, 3:49:51 AM
    Author     : Andriy
--%>

<%@page import="entity.ProductList"%>
<%@page import="entity.Orders"%>
<%@page import="java.util.Iterator"%>
<%@page import="java.util.List"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link rel="stylesheet" type="text/css" href="css/courier.css">
        <title>Order Detail</title>
    </head>
    <body>
         <header>
            <div id ="top_name"> <h1> Courier Dashboard: Order Detail</h1> </div>
            <div id="user-panel">
                <p> <a href="user_name.jsp">User name</a>
                    <a href="main.jsp">LogOut</a> </p>
            </div>
            </header>
        <div id="main">
            <div id="role"> <select name="rol" size = 1> 
                        <option value=”1”>Customer</option>
                        <option value=”2”>Warehouse Employee</option> 
                        <option value=”3”>Courier</option> 
                        <option value=”4”, selected>Admin</option> 
                            </select> </div>
            <div id="tabl" >
                <% if (request.getAttribute("error") == null) {
                        Orders order = (Orders) request.getAttribute("order");%>
                <table width="50%">

                    <TR>
                        <td id="head_table_first" >Order </td>
                        <td id="colomn_first" > <%=order.getIdOrder()%></td> 
                    </TR>
                    <TR>
                        <td id="head_table_first">Order Date </td>
                        <td id="colomn_first" > <%=order.getOrderDate()%></td> 
                    </TR>

                    <TR>
                        <td id="head_table_first">  Order Status</td>
                        <td id="colomn_first" > <%=order.getOrderStatus()%></td> 
                    </TR>

                    <TR>
                        <td id="head_table_first">Warehouse </td>
                        <td id="colomn_first" > <%=order.getIdWarehouse().getName()%>,<%=order.getIdWarehouse().getAddress()%></td> 
                    </TR>

                    <TR>
                        <td id="head_table_first">Address </td>
                        <td id="colomn_first" > <%=order.getAddress()%></td>
                    </TR>

                    <TR>
                        <td id="head_table_first">  Shipping price</td>
                        <td id="colomn_first" > <%=order.getShippingPrice()%></td>
                    </TR>

                    <TR>
                        <td id="head_table_first">  Product price</td>
                        <td id="colomn_first" > <%=order.getProductPrice()%></td>
                    </TR>

                    <TR>
                        <td id="head_table_first">  Product price</td>
                        <td id="colomn_first" > <%=order.getProductPrice()%></td>
                    </TR>
                    <TR>
                        <td id="head_table_first">  User</td>
                        <td id="colomn_first" > <%if (order.getIdUser() != null) {%><%=order.getIdUser().getLastName()%>,<%=order.getIdUser().getFirstName()%> <% } else {%>Unregistered<%}%></td>
                    </TR>
                    <TR>
                        <td id="head_table_first">  Email</td>
                        <td id="colomn_first" > <%=order.getEMail()%></td>
                    </TR>

                    <TR>
                        <td id="head_table_first">  Product price</td>
                        <td id="colomn_first" > <%=order.getProductPrice()%></td>
                    </TR>
                </table> 
                    <table>
                        <TR>
                            <td id="head_table_first" >Product name </td>
                            <td id="head_table_first" >Price </td>
                        </TR>
                        <%for(Iterator<ProductList> itr = order.getProductListCollection().iterator(); itr.hasNext();){
                            ProductList pl = itr.next();%>
                        <TR>
                            <td id="colomn_first"><%=pl.getProduct().getName()%></td>
                            <td id="colomn_first"><%=pl.getProduct().getPrice()%></td>
                        </TR>
                      <% }%>
                    </table>
                <form name="addComment"  method="POST" action="courier">
                    <input type="text" name="comment" size="100"/>
                    <input type="hidden" name="idOrderDel" value="<%=order.getIdOrder()%>"/>
                    <input type="submit" value="Add comment"/> 
                </form>

                <form name="setDeliuvered" method="POST" action="courier">

                    <input type="hidden" name="idOrderDeliver" value="<%=order.getIdOrder()%>"/>
                    <input type="submit" value="Set delivered"/> 
                </form>




                <%} else %>NO such order!
            </div>

        </div>
    </body>
</html>
